package per.turtle.system.feign;

import org.springframework.cloud.openfeign.FeignClient;
import org.springframework.http.MediaType;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RequestPart;
import org.springframework.web.multipart.MultipartFile;
import per.turtle.common.core.constant.ServiceNameConstants;
import per.turtle.common.core.web.entity.CommonResult;
import per.turtle.system.dto.SysFile;
import per.turtle.system.feign.factory.RemoteFileFallbackFactory;

/**
 * 文件服务
 *
 * @author turtle
 */
@FeignClient(contextId = "remoteFileService", value = ServiceNameConstants.FILE_SERVICE, fallbackFactory = RemoteFileFallbackFactory.class)
public interface RemoteFileService {

    /**
     * 上传文件
     *
     * @param file  文件信息
     * @param isPub 是否公开
     * @return 结果
     */
    @PostMapping(value = "upload", consumes = MediaType.MULTIPART_FORM_DATA_VALUE)
    CommonResult<SysFile> upload(@RequestPart(value = "file") MultipartFile file, @RequestParam(value = "isPub") boolean isPub);

}
